package br.pucrs.lognplay.entity;

import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "USER_")
public class User extends GenericEntity<String> {

	private static final long serialVersionUID = 1L;

	public enum Role {
		MASTER_USER("Master User"), CLIENT_MASTER_USER("Client Master User"), CLIENT_USER("Client User");

		private final String label;

		Role(String label) {
			this.label = label;
		}

		public String getLabel() {
			return label;
		}
	}

	@Id
	@Column(name = "ID_")
	private String id;

	@Column(name = "NAME_")
	private String name;

	@Column(name = "EMAIL_")
	private String email;

	@Column(name = "USERNAME_")
	private String username;

	@Column(name = "PASSWORD_")
	private String password;

	@Enumerated(EnumType.STRING)
	@Column(name = "ROLE_")
	private Role role;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "CLIENT_ID_", referencedColumnName = "ID_")
	private Client client;

	public User() {

	}

	public User(UUID id) {
		this.id = id.toString();
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}
}
